import {connect} from 'react-redux'
import {bindActionCreators} from 'redux'
import channelActions from '../../store/entities/channels/actions'
import HomeScreen from './HomeScreen'

const mapStateToProps = state => {

  const {
    entities: {channels},
    pagination: {channelsByType}
  } = state

  const channelsPagination = channelsByType['nav'] || {ids: []}
  const channelsState = channelsPagination.ids.map(id => channels[id])
  return {
    channels: channelsState,
  }
}


const mapDispatchToProps = dispatch => (
  {
    actions: bindActionCreators(channelActions, dispatch)
  }
)

export default connect(mapStateToProps,mapDispatchToProps)(HomeScreen)
